/* 
 * File:   DocumentManager.h
 * Author: taylor
 *
 * Created on November 7, 2012, 2:27 PM
 */

#ifndef DOCUMENTMANAGER_H
#define	DOCUMENTMANAGER_H

#include<vector>
#include<string>
#include<fstream>

#include "Document.h"
#include "IndexHandler.h"
#include "DocumentParser.h"
#include "Term.h"
#include "rapidxml.hpp"

using namespace std;
using namespace rapidxml;

class DocumentManager {
public:
    /**
     * Read the stopword list into the stopwords vector
     * @param filename the filename of the file to read stopwords from
     */
    void readStopWordList(string filename);

    /**
     * Add all documents from a given file to the structure
     * @param fileName the filename of the file to parse all documents from
     */
    void addDocumentsFromFile(string fileName);
    
    /**
     * Add a document to the document map, DOES NOT parse the document in any way
     * @param id the ID of the document
     * @param document the Document object
     */
    void addDocument(int id, Document document);
    
    /**
     * Get the entire documents map
     * @return a ptr to the map of documents
     */
    map<int,Document>* getDocuments();
    
    /**
     * Pointer to the index handler
     * @return a ptr to the IndexHandler object
     */
    IndexHandler* getTerms();
    
    /**
     * Return a document matching the given ID
     * @param docID
     * @return the document object matching docID
     */
    Document getDocument(int docID);
    
    /**
     * Check if a document exists in the map
     * @param docID
     * @return true if the document exists, false otherwise
     */
    bool documentExists(int docID);
    
    /**
     * Constructor for document manager
     * @param type type of structure to use a=avl tree, h=hash table
     */
    DocumentManager(char type);
private:
    vector<string> _stopWordsList;
    map<int,Document> _documents; //map containing document ID as the key, document object as the value; used for storing full information about all documents
    IndexHandler _terms;
};

#endif	/* DOCUMENTMANAGER_H */

